#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<unordered_set>
#include<unordered_map>
#include<numeric>
#include<queue>
#include<iomanip>
#define no "No\n"
#define yes "Yes\n"
#define int long long
#define INPUT "string.in"
#define OUTPUT "string.out"
using namespace std;
int edit(string s, string t) {
    const int n = s.size(), m = t.size();
    vector<vector<int>>dp(n + 1, vector<int>(m + 1, 0));
    for (int i = 1; i <= n; i++) {
        dp[i][0] = i;
    }
    for (int j = 1; j <= m; j++) {
        dp[0][j] = j;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s[i - 1] == t[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1];
            }
            else {
                dp[i][j] = min({ dp[i][j - 1],dp[i - 1][j],dp[i - 1][j - 1] }) + 1;
            }
        }
    }
    return dp[n][m];
}
signed main() {
#if not defined TEST
    freopen(INPUT, "r", stdin);
    freopen(OUTPUT, "w", stdout);
#endif
    int t;
    cin >> t;
    while (t--) {
        string a, b;
        cin >> a >> b;
        cout << (edit(a, b) == 1 ? yes : no);

    }
#if not defined TEST
    fclose(stdin);
    fclose(stdout);
#endif
    return 0;
}


